<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/axios-0.18.0.js"></script>
    <script src="../js/vue.js"></script>
</head>
<body>
    <div id="app">
        <h3>添加品牌</h3>
        <form action="" method="post">
            品牌名称：<input id="brandName" name="brandName" v-model="brand.brandName"><br>
            企业名称：<input id="companyName" name="companyName" v-model="brand.companyName"><br>
            排序：<input id="ordered" name="ordered" v-model="brand.ordered"><br>
            描述信息：<input id="description" name="description" v-model="brand.description"><br>
            状态：<input type="radio" name="status" v-model="brand.status" value="1">启用
            <input type="radio" name="status" v-model="brand.status" value="0">禁用<br>

            <input type="button" id="btn" v-on:click="submitFrom" value="提交"/>
        </form>
    </div>
</body>
<script>
    new Vue ({
        el:"#app",
        data:function () {
            return {
                brand:{}
            }
        },
        methods: {
            submitFrom() {
                var _this = this;
                axios({
                    method:"post",
                    url:"http://localhost:8080/BigHomeworkProject/addBrandServlet",
                    data: _this.brand
                }).then(resp => {
                    if(resp.data == "success") {
                        alert("新增成功");
                        window.location.href = "http://localhost:8080/BigHomeworkProject/html/Demo-item.html";
                    }
                });
            }
        }
    })
</script>
</html>